//
//  NewsTableViewCell.m
//  BSLCar
//
//  Created by 孙卓 on 15/5/22.
//  Copyright (c) 2015年 lyz. All rights reserved.
//

#import "NewsTableViewCell.h"

@interface NewsTableViewCell ()


@end

@implementation NewsTableViewCell
//重写初始化
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self creatMyCell];
    }
    return self;
}

- (void)dealloc
{
    [_imgIcon release];
    [_timeLabel release];
    [_txtLabel release];
    [_label release];
    [_titleLabel release];
    [super dealloc];
}

//初始化加添加到contentview
- (void)creatMyCell{
    self.imgIcon = [[UIImageView alloc] init];
    [self.contentView addSubview:self.imgIcon];
    self.titleLabel = [[UILabel alloc] init];
    [self.contentView addSubview:self.titleLabel];
    self.txtLabel = [[UILabel alloc] init];
    [self.contentView addSubview:self.txtLabel];
    self.timeLabel = [[UILabel alloc] init];
    [self.contentView addSubview:self.timeLabel];
    self.label = [[UILabel alloc] init];
    [self.contentView addSubview:self.label];
}
//给写边框的框架
- (void)layoutSubviews{
    [super layoutSubviews];
    self.contentView.backgroundColor = [UIColor colorWithRed:231 / 255.0 green:231 / 255.0 blue:231 / 255.0 alpha:1];
    //self.contentView.layer.cornerRadius = 20;
    //self.contentView.layer.masksToBounds = YES;

    self.imgIcon.frame = CGRectMake(5, 42, 155 , 120 );
    self.imgIcon.backgroundColor = [UIColor clearColor];
    self.imgIcon.layer.cornerRadius = 5;
    self.imgIcon.layer.masksToBounds = YES;
    
    self.imgIcon.contentMode = UIViewContentModeScaleAspectFit;
    
    self.titleLabel.frame = CGRectMake(10, 2, self.contentView.frame.size.width - 32, 30);
        self.titleLabel.backgroundColor = [UIColor clearColor];
//    self.titleLabel.font = [UIFont boldSystemFontOfSize:20];
    self.titleLabel.font = [UIFont systemFontOfSize:16];
    //顺序很重要
    self.titleLabel.numberOfLines = 2;
    [self.titleLabel sizeToFit];

    self.txtLabel.frame = CGRectMake(170, 75, self.bounds.size.width - 175,60);
    self.txtLabel.backgroundColor = [UIColor clearColor];
//    self.txtLabel.textAlignment = NSTextAlignmentCenter;
    self.txtLabel.font = [UIFont systemFontOfSize:14];
    self.txtLabel.numberOfLines = 3;
    [self.txtLabel sizeToFit];
    
    self.timeLabel.frame = CGRectMake(100, 35, self.bounds.size.width - 115, 10);
    self.timeLabel.backgroundColor = [UIColor clearColor];
    self.timeLabel.textAlignment = NSTextAlignmentRight;
    self.timeLabel.font = [UIFont systemFontOfSize:14];
    self.timeLabel.textColor = [UIColor redColor];
    
    self.label.frame = CGRectMake(50, 138, self.bounds.size.width - 70, 20);
    self.label.textColor = [UIColor blueColor];
    self.label.textAlignment = NSTextAlignmentRight;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
